<%@page import="java.net.*"%>
<%@page import="java.io.*"%>
<%@page import="edu.stanford.prpl.dynUI.*"%>
<%@page import="edu.stanford.prpl.dynUI.templates.*"%>
<%

      // System.out.println("Starting lightweight UI Template package...");
      // request.getContextPath()   // Gets me the current URL
      // PRPLAppClient prplAppClient1 = (PRPLAppClient) session.getAttribute(PRPLManagementUI.APP_CLIENT);
      // String sessionKey = request.getParameter(FacebookParam.SESSION_KEY.toString());

      UIEngine webUI_engine = (UIEngine)session.getAttribute("MousedeerUIEngine");
      String pageTitle  = URLDecoder.decode(request.getParameter("pageTitle"), "UTF-8");
      String actionCall = request.getParameter("actionCall");
      
      // System.out.println("\n\nactionCall => "+actionCall+"\n\n");
      
      // String filePath = application.getRealPath("DynNaviList.template.xml");
      // out.println("DynNaviList.template.xml => "+filePath);
      // String templateFilePath = application.getRealPath("DynNaviList.template.xml");
      // webUI_engine.setTemplate(new BufferedReader(new FileReader(templateFilePath)));

      URL dataXml = new URL(actionCall);
      BufferedReader in = new BufferedReader(
                              new InputStreamReader(dataXml.openStream())
                          );
      Object UIresult = webUI_engine.render(in, pageTitle, UIEngine.renderType.AJAX_WEB_FRAGMENT);

      if (UIresult instanceof String) {
          // System.out.println("\nHTML fragment output: \n"+(String)UIresult);         
          out.println((String)UIresult);
      }
      if (UIresult == null)
          out.println("\n\nUI Fragment Result is NULL! \n");


%>